import 'package:get/get.dart';
import 'package:sprintf/sprintf.dart';
import 'package:yt_devops/pages/devices/device_tab/model/device_item_model.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/utils/enums.dart';
import 'package:yt_devops/utils/formats.dart';
import 'package:yt_devops/utils/liquid_formats.dart';
import 'package:yt_devops/utils/self_develop_formats.dart';

class BatteryPackDetailModel {
  // DetailItemModel controlItemsMain = DetailItemModel(
  //     label: 'siteMonitor.mainContactorStatus'.tr,
  //     field: 'contactorStatus',
  //     format: Formates.contactorFormat); //'主接触器状态'

  // DetailItemModel controlItemsMainYT = DetailItemModel(
  //     label: 'siteMonitor.mainContactorStatus'.tr,
  //     field: 'bmsOpenAndClose',
  //     format: Formates.closeFormat); //'主接触器状态'

  // DetailItemModel controlItemsMainLiquid = DetailItemModel(
  //     label: 'siteMonitor.mainContactorStatus'.tr,
  //     field: 'MainContactorStatus',
  //     format: Formates.closeFormat); //'主接触器状态'
  List<DetailItemModel> getControllItems(int productId) {
    return [
      if (productId != ProductIDType.liquidEnergyBatteryStack.value)
        DetailItemModel(
          label: 'siteMonitor.prechargeContactorStatus'.tr, //'预充接触器状态',
          field: 'PrechargeContactorStatus',
          format: Formates.closeSelfDevelopFormat,
        ),
      DetailItemModel(
        label: ResKey.deviceDcCircuitBreakerCondition.tr,
        field: 'DCCircuitBreakerStatus',
        format: Formates.closeFormat,
      ),
      DetailItemModel(
        label: ResKey.deviceAcCircuitBreakerCondition.tr,
        field: 'ACCircuitBreakerStatus',
        format: Formates.closeSelfDevelopFormat,
      ),
      if (productId == ProductIDType.liquidEnergyBatteryStack.value) //'主接触器状态'
        DetailItemModel(
            label: 'siteMonitor.mainContactorStatus'.tr,
            field: 'MainContactorStatus',
            format: Formates.closeFormat)
      else if (productId == ProductIDType.yTEnergyBatteryStack.value)
        DetailItemModel(
            label: 'siteMonitor.mainContactorStatus'.tr,
            field: 'bmsOpenAndClose',
            format: Formates.closeFormat)
      else
        DetailItemModel(
            label: 'siteMonitor.mainContactorStatus'.tr,
            field: 'contactorStatus',
            format: Formates.contactorFormat),
      DetailItemModel(
          label: 'siteMonitor.externalFaultStatus'.tr, // '对外故障',
          field: 'externalFaultStatus',
          format: Formates.alarmArrFormat),
      DetailItemModel(
          label: 'siteMonitor.chargeDischargeIndication'.tr, // '充放电指示',
          field: 'CADI',
          format: Formates.chargeFormat),
      DetailItemModel(
          label: 'siteMonitor.firstLevelAlarm'.tr, // '一级报警',
          field: 'firstLevelAlarm',
          format: Formates.alarmArrFormat),
      DetailItemModel(
          label: 'siteMonitor.secondLevelAlarm'.tr, // '二级报警',
          field: 'secondLevelAlarm',
          format: Formates.alarmArrFormat),
      DetailItemModel(
          label: 'siteMonitor.threeLevelAlarm'.tr, // '三级报警',
          field: 'threeLevelAlarm',
          format: Formates.alarmArrFormat),
    ];
  }

  List<DetailItemModel> statusItems = [
    DetailItemModel(
      label: 'siteMonitor.prechargeContactorStatus'.tr, //'预充接触器状态',
      field: 'PrechargeContactorStatus',
      format: Formates.closeSelfDevelopFormat,
    ),
    DetailItemModel(
      label: ResKey.deviceDcCircuitBreakerCondition.tr,
      field: 'DCCircuitBreakerStatus',
      format: Formates.closeFormat,
    ),
    DetailItemModel(
      label: ResKey.deviceAcCircuitBreakerCondition.tr,
      field: 'ACCircuitBreakerStatus',
      format: Formates.closeSelfDevelopFormat,
    ),
    // DetailItemModel(
    //     label: ResKey.deviceMainContactorStatus.tr,
    //     field: 'bmsOpenAndClose',
    //     format: Formates.closeFormat),
    DetailItemModel(
        label: 'siteMonitor.externalFaultStatus'.tr, // '对外故障',
        field: 'externalFaultStatus',
        format: Formates.alarmArrFormat),
    DetailItemModel(
        label: 'siteMonitor.chargeDischargeIndication'.tr, // '充放电指示',
        field: 'CADI',
        format: Formates.chargeFormat),
    DetailItemModel(
        label: 'siteMonitor.firstLevelAlarm'.tr, // '一级报警',
        field: 'firstLevelAlarm',
        format: Formates.alarmArrFormat),
    DetailItemModel(
        label: 'siteMonitor.secondLevelAlarm'.tr, // '二级报警',
        field: 'secondLevelAlarm',
        format: Formates.alarmArrFormat),
    DetailItemModel(
        label: 'siteMonitor.threeLevelAlarm'.tr, // '三级报警',
        field: 'threeLevelAlarm',
        format: Formates.alarmArrFormat),
  ];

  List<DetailItemModel> runItems = [
    DetailItemModel(
        label: 'siteMonitor.current'.tr, // '电流',
        field: 'TotalBatteryCurrent',
        format: Formates.currentFormat),
    DetailItemModel(
        label: 'siteMonitor.voltage'.tr, // '电压',
        field: 'TotalBatteryVoltage',
        format: Formates.voltageFormat),
    DetailItemModel(
        label: 'SOC', field: 'SOC', format: Formates.percentageFormat),
    DetailItemModel(
        label: 'SOH', field: 'SOH', format: Formates.percentageFormat),
    DetailItemModel(
        label: 'siteMonitor.insulationValue'.tr, // '绝缘值',
        field: 'InsulationValue',
        format: Formates.kohmFormat),
    DetailItemModel(
        label: 'siteMonitor.positiveInsulationValue'.tr, //'正极绝缘值',
        field: 'PositiveInsulationValue',
        format: Formates.kohmFormat),
    DetailItemModel(
        label: 'siteMonitor.negativeInsulationValue'.tr, // '负极绝缘值',
        field: 'NegativeInsulationValue',
        format: Formates.kohmFormat),
    DetailItemModel(
        label: 'siteMonitor.averageVoltage'.tr, //'平均电压',
        field: 'AverageVoltage',
        format: Formates.voltageFormat),
    DetailItemModel(
        label: 'siteMonitor.prechargeTotalPressure'.tr, //'预充总压',
        field: 'TPCP',
        format: Formates.voltageFormat),
    DetailItemModel(
        label: ResKey.deviceWaterImmersionSignal.tr, // '水浸信号',
        field: 'waterImmersionSignal',
        format: Formates.faultFormat),
    DetailItemModel(
        label: 'BMU1-${sprintf(ResKey.deviceCommunicationStatusSentence.tr, [
              10
            ])}', //'BMU1-10通信状态',
        field: 'BMU1CS',
        format: Formates.faultFormat),
    DetailItemModel(
        label: ResKey.deviceLightningArresterFailure.tr, //交流防雷器故障
        field: 'aCLightningArresterFailure',
        format: Formates.faultFormat),
    DetailItemModel(
        label: 'siteMonitor.accessControlStatus'.tr, //'门禁状态',
        field: 'AccessControlStatus',
        format: SelfDevelopFormate.doorFormat),
    DetailItemModel(
        label: ResKey.deviceAbnormalDisconnectionSwitch.tr, //'隔开开关异常断开',
        field: 'abnormalDisconnectionOfTheIsolationSwitch',
        format: Formates.faultFormat),
  ];

  List<DetailItemModel> maxUnitData = [
    DetailItemModel(
        label: 'siteMonitor.maximumCellVoltage'.tr, // '最高电芯电压',
        field: 'MVVOASU',
        format: Formates.voltageFormat),
    DetailItemModel(
      label: 'siteMonitor.numberCode'.tr, //'编号',
      field: 'MaxNOIV',
    ),
    DetailItemModel(
        label: 'siteMonitor.minimumCellVoltage'.tr, // '最低电芯电压',
        field: 'MVVOSU',
        format: Formates.voltageFormat),
    DetailItemModel(
      label: 'siteMonitor.numberCode'.tr, //'编号',
      field: 'MNOIV',
    ),
    DetailItemModel(
        label: 'siteMonitor.maximumTemperaturePoint'.tr, // '最高电芯温度',
        field: 'MaximumIndividualTemperature',
        format: Formates.unitTempFormat),
    DetailItemModel(
      label: 'siteMonitor.temperaturePoint'.tr, //'温度点',
      field: 'MITN',
    ),
    DetailItemModel(
        label: 'siteMonitor.minimumTemperaturePoint'.tr, // '最低电芯温度',
        field: 'LVOMT',
        format: Formates.unitTempFormat),
    DetailItemModel(
      label: 'siteMonitor.temperaturePoint'.tr, // '温度点',
      field: 'MNOIT',
    ),
  ];
  List<DetailItemModel> historyItems = [
    DetailItemModel(
        label: 'siteMonitor.singleCharge'.tr, //'单次充电量',
        field: 'LastChargeLevel',
        format: Formates.powerHourFormat),
    DetailItemModel(
        label: 'siteMonitor.singleDischarge'.tr, //'单次放电量',
        field: 'LastDischargeCapacity',
        format: Formates.powerHourFormat),
    DetailItemModel(
        label: 'siteMonitor.cumulativeCharge'.tr, //'累计充电量',
        field: 'ACC',
        format: Formates.powerHourFormat),
    DetailItemModel(
        label: 'siteMonitor.cumulativeDischarge'.tr, //'累计放电量',
        field: 'ADC',
        format: Formates.powerHourFormat),
    DetailItemModel(
        label: 'siteMonitor.numberBatteryCabinetDoors'.tr, // '电池柜开门次数',
        field: 'NOBCDO'),
  ];
  List<DetailItemModel> tempItems = [
    DetailItemModel(
        label: 'siteMonitor.averageTemperature'.tr, //'平均温度',
        field: 'AverageTemperature',
        format: Formates.tempFormat),
    DetailItemModel(
        label: '${'siteMonitor.highboxTemperature'.tr}1', //'高压箱温度1'
        field: 'HighPressureBoxTemperature1',
        format: Formates.tempFormat),
    DetailItemModel(
        label: '${'siteMonitor.highboxTemperature'.tr}2', //'高压箱温度2'
        field: 'HighPressureBoxTemperature2',
        format: Formates.tempFormat),
    DetailItemModel(
        label: '${'siteMonitor.highboxTemperature'.tr}3', //'高压箱温度3'
        field: 'HighPressureBoxTemperature3',
        format: Formates.tempFormat),
    DetailItemModel(
        label: '${'siteMonitor.highboxTemperature'.tr}4', //'高压箱温度4'
        field: 'HighPressureBoxTemperature4',
        format: Formates.tempFormat),
  ];
  List<DetailItemModel> abilityItems = [
    DetailItemModel(
        label: 'siteMonitor.rechargeableCapacity'.tr, // '可充电量',
        field: 'RechargeableCapacity',
        format: Formates.powerHourFormat),
    DetailItemModel(
        label: 'siteMonitor.dischargeCapacity'.tr, //可放电量
        field: 'DischargeableCapacity',
        format: Formates.powerHourFormat),
    DetailItemModel(
        label: 'siteMonitor.maximumChargingCurrent'.tr, // '最大充电电流',
        field: 'MaximumChargingCurrent',
        format: Formates.currentFormat),
    DetailItemModel(
        label: 'siteMonitor.maximumDischargingCurrent'.tr, //'最大放电电流',
        field: 'maximumDischargeCurrent',
        format: Formates.currentFormat),
  ];
}
